<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Events</title>

<script type="text/javascript">

function showEvents() {
	  var xmlhttp=new XMLHttpRequest();
	  xmlhttp.onreadystatechange=function() {
	    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
	      	document.getElementById("events").innerHTML=xmlhttp.responseText;
	    }
	  }
	  xmlhttp.open("GET","eventController.php?a=getEvents",true);
	  xmlhttp.send();
	}

function addEvent() {
	  var xmlhttp=new XMLHttpRequest();
	  xmlhttp.open("GET","eventController.php?a=addEvent&name="+ 
			  document.getElementById("eventName").value 
			  ,true);
	  xmlhttp.send();
	  
	  setTimeout(showEvents,100);
	}


function removeEvent(sender) {
	
	
        	   var xmlhttp=new XMLHttpRequest();
        		  xmlhttp.open("GET","eventController.php?a=removeEvent&id="+  sender
        				  ,true);
        		  xmlhttp.send();   
	  
	  setTimeout(showEvents,100);
	}



</script>

</head>
<body onload="showEvents();">

<a href="logOut.php">Log out</a><br/>
<a href="account.php">Account settings</a><br/>
<a href="emails.php">Emails settings</a><br/>

<b> Events </b> <br/>

 <ul id="events">
</ul> 

<input type="text" id="eventName">
<input type="submit" value="Add Event" onclick="addEvent()">


</body>
</html>